package demo1;

class Animal{
    public String name;
    public int age;

    public Animal(String name,int age){
        this.name=name;
        this.age=age;
    }

    public void eat(){
        System.out.println(this.name+"正在吃...");
    }
}

class Dog extends Animal{

    public String color;
    public Dog(String name,int age,String color){
        super(name, age);
        this.color=color;
    }
    public void eat(){
        System.out.println(this.name+"正在吃狗粮...");
    }

    public void barks(){
        System.out.println(this.name+"正在汪汪叫...");
    }
}


class Bird extends Animal{
    public Bird(String name,int age){
        super(name, age);
    }

    public void fly(){
        System.out.println(this.name+"正在飞....");
    }
    public void eat(){
        System.out.println(this.name+"正在吃鸟粮...");
    }
}
public class Test {
    public static void main(String[] args) {
        Animal animal=new Dog("来宝",4,"黄色");
       // animal.eat();
        Dog dog =(Dog)animal;
        dog.eat();
        Animal animal1 =new Bird("布谷",5);
        Bird bird = (Bird)animal1;
        bird.eat();
        animal1.eat();
    }
}
